package com.tengju.user.domain.model.archive.sign;

import com.tengju.user.domain.model.archive.letax.IdentityType;
import com.tengju.user.domain.model.user.UserIdCode;
import lombok.Value;
import lombok.experimental.NonFinal;

import java.time.LocalDateTime;

@Value
public class Sign {

    private SignId signId;

    private UserIdCode idCode;

    private String platformCode = "DT";

    @NonFinal
    private IdentityType beforeIdentity;

    @NonFinal
    private IdentityType currentIdentity;

    @NonFinal
    private IdentityType historyIdentity;

    @NonFinal
    private String isSigned;

    @NonFinal
    private String isView;

    @NonFinal
    private LocalDateTime signTime;

    @NonFinal
    private Integer noticeStatus;


    public Boolean isSelfCertified() {
        return IdentityType.CERTIFIED_BUSINESS == currentIdentity ||
                IdentityType.CERTIFIED_INDIVIDUAL == currentIdentity;
    }

    public Boolean isRegister() {
        return IdentityType.REGISTER_SOHO == currentIdentity;
    }

    public void change(Integer noticeStatus) {
        this.noticeStatus = noticeStatus;
    }

    public void change(IdentityType beforeIdentity,
            IdentityType currentIdentity) {
        this.beforeIdentity = beforeIdentity;
        this.currentIdentity = currentIdentity;
    }

    public void notFirst() {
        this.isView = "NOT_FIRST";
    }

    public void changeIsSigned() {
        this.isSigned = "yes";
        this.signTime = LocalDateTime.now();
    }

    public void changeSign2Yes(IdentityType beforeIdentity,
            IdentityType currentIdentity,
            IdentityType historyIdentity,
            String isView) {
        this.beforeIdentity = beforeIdentity;
        this.currentIdentity = currentIdentity;
        this.historyIdentity = historyIdentity;
        this.isSigned = "yes";
        this.signTime = LocalDateTime.now();
        this.isView = isView;
    }

    public void changeSign2No(IdentityType beforeIdentity,
            IdentityType currentIdentity,
            IdentityType historyIdentity) {
        this.beforeIdentity = beforeIdentity;
        this.currentIdentity = currentIdentity;
        this.historyIdentity = historyIdentity;
        this.isSigned = "no";
    }

    public void change(IdentityType beforeIdentity,
            IdentityType currentIdentity,
            IdentityType historyIdentity,
            String isSigned,
            String isView) {
        this.beforeIdentity = beforeIdentity;
        this.currentIdentity = currentIdentity;
        this.historyIdentity = historyIdentity;
        this.isSigned = isSigned;
        this.isView = isView;
    }
}
